window.onload = function(){
	var requestUrl = '/officalWebsite/admin?method=getAdminInfo';
	var logoutUrl = '/officalWebsite/admin?method=logout'
	var str = window.parent.location.search;	//获取到"?key=.."
	var key = str.substring(str.indexOf("=")+1);
	var hidInput = document.querySelector('.right input[type="hidden"]');
	ajax({
		method : 'post',
		url : requestUrl,
		async : true,
		data : {
			'key' : key
		},
		success : function(data){
			if(data!=""&&data!=null){
				data = JSON.parse(data);
				var faceImg = document.querySelector('.left img');
				var span = document.querySelector('#adminName');
				if(data.adminFacePath!=""){
					faceImg.src = data.adminFacePath;
				}
				span.innerHTML = data.adminName;
				hidInput.value = key;
			}
		}
	});
	// 退出
	var logoutLi = document.querySelector('#logout');
	EventListener.addEvent(logoutLi, 'click', function(){
		var bool = confirm('是否确认退出?');
		if(bool){
			ajax({
				method : 'get',
				url : logoutUrl,
				async : true,
				data : {
					'key' : hidInput.value
				},
				success : function(data){
					if(data=="true"){
						window.parent.location.href = '/officalWebsite/admin/login.html';
					}else{
						alert('退出异常!');
					}
				}
			});
		}
	});
}